package praktikumid.w10.p1;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.event.MouseEvent;

/**
 * An abstract class for all the shapes. 
 * The idea is that every shape knows how
 * to draw itself. Also, every shape
 * knows how to handle different
 * mouse events. DrawPanel just delegates
 * all the events to the shapes.
 * @author Ago
 *
 */
public abstract class Shape {
	
	/**
	 * Whether the shape is finished.
	 */
	boolean isFinished = false;
	/**
	 * The color of the shape. 
	 * Default is black.
	 */
	private Color color = Color.BLACK;
	
	/**
	 * Draws the shape. Every shape
	 * should override it to implement
	 * real drawing. This method here
	 * only sets the color.
	 * @param g Graphics from the panel
	 */
	public void paintComponent(Graphics g) {
		g.setColor(color);
	}
	
	/**
	 * Mouse drag event delegated from the panel.
	 * @param e Mouse event object
	 */
	public abstract void drag(MouseEvent e);
	
	/**
	 * Mouse click event delegated from the panel.
	 * @param e Mouse event object
	 */
	public abstract void click(MouseEvent e);
	
	/**
	 * Mouse release event delegated from the panel.
	 * @param e Mouse event object
	 */
	public abstract void release(MouseEvent e);
	
	/**
	 * Moves the shape
	 * @param dx Delta x, how many pixels should
	 * the shape be moved.
	 * @param dy Delta y, how many pixels should
	 * the shape be moved.
	 */
	public abstract void move(int dx, int dy);
	
	/**
	 * Getter, whether the shape is finished.
	 * @return Whether the shape is finished.
	 */
	public boolean isFinished() {
		return isFinished;
	}
	
	/**
	 * Get method for the color
	 * @return The color of the shape
	 */
	public Color getColor() {
		return color;
	}
	
	/**
	 * Set method for the color
	 * @param c Sets the color of the shape
	 */
	public void setColor(Color c) {
		color = c;
	}
}
